import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserCarVO, UserCarForm, UserCarQuery } from '@/api/bzIns/userCar/types';

/**
 * 查询用户汽车列表
 * @param query
 * @returns {*}
 */

export const listUserCar = (query?: UserCarQuery): AxiosPromise<UserCarVO[]> => {
  return request({
    url: '/bzIns/userCar/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户汽车详细
 * @param carId
 */
export const getUserCar = (carId: string | number): AxiosPromise<UserCarVO> => {
  return request({
    url: '/bzIns/userCar/' + carId,
    method: 'get'
  });
};

/**
 * 新增用户汽车
 * @param data
 */
export const addUserCar = (data: UserCarForm) => {
  return request({
    url: '/bzIns/userCar',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户汽车
 * @param data
 */
export const updateUserCar = (data: UserCarForm) => {
  return request({
    url: '/bzIns/userCar',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户汽车
 * @param carId
 */
export const delUserCar = (carId: string | number | Array<string | number>) => {
  return request({
    url: '/bzIns/userCar/' + carId,
    method: 'delete'
  });
};
